package com.lishe.lishe.lishe.module.mall.presenter;

import com.lishe.lishe.lishe.common.Globals;
import com.lishe.lishe.lishe.module.mall.bean.GoodsMallResponse;
import com.lishe.lishe.lishe.module.mall.bean.HomeResponse;
import com.lishe.lishe.net.BaseHttpLoader;
import com.lishe.lishe.net.NetAPI;
import com.lishe.lishe.net.ResultListener;
import java.util.HashMap;
import java.util.Map;
import io.reactivex.Observable;
import okhttp3.ResponseBody;

/**
 * 标    题：
 * 功能描述：
 * 作    者：zouxx
 * 创建时间：2018/8/13
 */

public class IndexFragmentModule {


    public void getIndexTopData(ResultListener listener) {
        BaseHttpLoader http = new BaseHttpLoader(HomeResponse.class, Globals.LISHE_URL) {
            @Override
            public Observable<ResponseBody> structureObservable(NetAPI api) {
                return api.getIndexData();
            }
        };
        http.executor(listener);
    }

    public void getIndexLoveData(int page, ResultListener listener) {
        Map<String, String> params = new HashMap<>();
        params.put("pageSize","10");
        params.put("page",String.valueOf(page));
        BaseHttpLoader http = new BaseHttpLoader(GoodsMallResponse.class, Globals.LISHE_URL) {
            @Override
            public Observable<ResponseBody> structureObservable(NetAPI api) {
                return api.getYouLove(params);
            }
        };
        http.executor(listener);
    }

}
